﻿namespace Bookvar.UI
{
    public abstract class TopicConnectorBase : ITopicConnector
    {
        public abstract void Connect( TopicContentPresenter parent, TopicContentPresenter child );
        public abstract void Disconnect( TopicContentPresenter parent, TopicContentPresenter child );

        public void ConnectAll(TopicContentPresenter parent)
        {
            foreach (TopicContentPresenter child in parent.Children)
            {
                Connect(parent, child);
                ConnectAll(child);
            }
        }

        public void DisconnectAll(TopicContentPresenter parent)
        {
            foreach (TopicContentPresenter child in parent.Children)
            {
                Disconnect(parent, child);
                DisconnectAll(child);
            }
        }
    }
}
